#ifndef __SOFTTIMER_H__
#define __SOFTTIMER_H__
#include "stm32f4xx.h"
#include "stdbool.h"

#define STIMER_POLLING_CLK_MS      2

#define MAX_SOFT_TIMER_ID          7

#define MAX_PERIOD       0xffffffff

#define UART1_RX_TIMER_ID    0
#define UART2_RX_TIMER_ID    1
#define LED_TIMER_ID         2

typedef unsigned volatile long long timer_t;

typedef void timer_callback_t(void *);

typedef struct
{
	bool running;
	u32 ticks;       //
	u32 ticks_reload;
	u32 period;
	timer_callback_t *timer_callback;
}soft_timer_t;

extern soft_timer_t soft_timer[MAX_SOFT_TIMER_ID+1];

void soft_timer_init(void);
bool soft_timer_set(u8 timer_id,u32 time_ms,u32 period,timer_callback_t *call_back)	;
void soft_timer_cancel(u8 timer_id)	;
bool is_stimer_run(u8 timer_id);




u8 check_timer(timer_t timer);
timer_t get_one_timer(u32 time);


#endif



